<?php


namespace App\Http\Controllers\Estate;


use App\Http\Controllers\Controller;
use App\Models\EquipmentLevel;
use Illuminate\Http\Request;

class EquipmentLevelController extends Controller
{
    public $model;

    public function __construct(){
        $this->model = new EquipmentLevel();
    }

    /**
     *banner列表
     * @param Request $request
     * @return array
     */
    public function index(Request $request)
    {
        $where['status'] = 1;
        return $this->success( $this->model->getList($where,'id','desc'));
    }

    /**
     * 新增
     * @param Request $request
     * @return array
     */
    public function store(Request $request)
    {
        $data = $request->post();
        return $this->model->create($data) ? $this->success('添加成功!') : $this->error('添加失败!');
    }

    /**
     * 获取详情
     * @param $id
     * @return array
     */
    public function show($id)
    {
        return $this->success( $this->model->getInfo(['id' => $id]) );
    }

    /**
     * 编辑
     * @param Request $request
     * @return array
     */
    public function update(Request $request)
    {
        $data = $request->post();
        return $this->model->edit( $data) ? $this->success('修改成功!') : $this->error('修改失败!');
    }

    /**
     * 删除
     * @param Request $request
     * @return array
     */
    public function destroy ($ids)
    {
        return $this->model->deletes( $ids ) ? $this->success('删除成功!') : $this->error('删除失败!');
    }
}
